<template>
    <uni-forms ref="form">
        <uni-forms-item required label="" name="">
        </uni-forms-item>
        <button @click="commitData">提交</button>
        <button @click="getMobileCode">重置</button>
    </uni-forms>
    <view>计数: {{ store.count }}</view>
    <view>双倍: {{ store.double }}</view>
    <button @click="store.increment()">加1</button>
    <button @click="store.decrement()">减1</button>

    <uni-swipe-action>
        <uni-swipe-action-item :right-options="swipeOptions" @click="onDel" :left-options="swipeOptions">
            <view class="box">
                <text>滑动操作</text>
                <text>收藏</text>
            </view>
        </uni-swipe-action-item>
    </uni-swipe-action>
</template>
<script setup>
import { getCodeApi } from '@/apis/user';
import { http } from '@/utils/http'
import { useCounterStore } from '@/stores/counter'
import { ref } from 'vue'
const store = useCounterStore()
const commitData = async () => {
    console.log('提交');
    const res = await http.post('/login/password', {
        mobile: '13211112222',
        // 密码 abc123456 测试：出现非10000的情况
        password: 'abc12345'
    })
    console.log(res);
}

// 测试获取验证码
const getMobileCode = async () => {
    const res = await getCodeApi({ mobile: '13211112222', type: 'login' })
    console.log(res.code);
}
const swipeOptions = ref([
    {
        text: '删除',
        style: {
            backgroundColor: '#dd524d',
            color: '',
            fontSize: '',
        },
    },
    {
        text: '收藏',
        style: {
            backgroundColor: '#09bb07',
            color: '',
            fontSize: '',
        },
    },
])
const onDel = () => {
    uni.showToast({
        title: '删除成功',
        icon: 'none',
    })
}
</script>
<style lang="scss">
.box {
    width: 100%;
    height: 120rpx;
    background-color: pink;
    display: flex;
    align-items: center;
    justify-content: center;
}
</style>